package com.ooqiu.gaming.ui.setting;

import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ooqiu.gaming.R;
import com.ooqiu.gaming.base.BaseActivity;
import com.ooqiu.gaming.utils.SettingPrefUtil;
import com.ooqiu.gaming.view.Topbar;
import com.ooqiu.gaming.view.option_item.OptionItem;

import butterknife.BindView;
import butterknife.ButterKnife;

@Route(path = PushSettingActivity.PATH)
public class PushSettingActivity extends BaseActivity implements CompoundButton.OnCheckedChangeListener {
    public static final String PATH = "/gn/setting/push_setting";
    @BindView(R.id.topbar)
    Topbar mTopbar;
    @BindView(R.id.option_push_news)
    OptionItem mOptionPushNews;
    @BindView(R.id.option_push_apply)
    OptionItem mOptionPushApply;
    @BindView(R.id.option_push_night)
    OptionItem mOptionPushNight;
    @BindView(R.id.swich_allow_push_news)
    Switch mSwichAllowPushNews;
    @BindView(R.id.swich_allow_push_apply)
    Switch mSwichAllowPushApply;
    @BindView(R.id.swich_allow_push_night)
    Switch mSwichAllowPushNight;

    @Override
    public int initContentView() {
        return R.layout.activity_push_setting;
    }

    @Override
    public void initInjector() {
        ButterKnife.bind(this);
    }

    @Override
    public void initUiAndListener() {



        mSwichAllowPushNews.setChecked(SettingPrefUtil.isAllowNewsPush(mContext));
        mSwichAllowPushApply.setChecked(SettingPrefUtil.isAllowApplyPush(mContext));
        mSwichAllowPushNight.setChecked(SettingPrefUtil.isAllowNightPush(mContext));

        mSwichAllowPushNews.setOnCheckedChangeListener(this);
        mSwichAllowPushApply.setOnCheckedChangeListener(this);
        mSwichAllowPushNight.setOnCheckedChangeListener(this);
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isApplyStatusBarColor() {
        return true;
    }

    @Override
    protected Toolbar toolbarIdRes() {
        return mTopbar;
    }

    @Override
    protected View statusLayoutId() {
        return null;
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        switch (buttonView.getId()) {
            case R.id.swich_allow_push_news:
                SettingPrefUtil.setAllowNewsPush(mContext, isChecked);
                break;
            case R.id.swich_allow_push_apply:
                SettingPrefUtil.setAllowApplyPush(mContext, isChecked);
                break;
            case R.id.swich_allow_push_night:
                SettingPrefUtil.setAllowNightPush(mContext, isChecked);
                break;
        }
    }
}
